/**
 * Created by mac1 on 2017/11/14.
 */
var redis = require('redis');
var client = redis.createClient(6379,'127.0.0.1');
client.on('error',function (err) {
  console.log('Error ' + err);
});
client.set('color', 'red',redis.print);
client.get('color', function (err, value) {
  if (err) throw err;
  console.log('Got: ' + value);
});
client.hmset('camping',{
  'shelter':'2-person tent',
  'cooking':'campstove',
}, redis.print);

client.hget('camping','cooking',function (err, value) {
  if (err) throw err;
  console.log('Will be cooking with: '+value);
});
client.hkeys('camping',function (err, keys) {
  if (err) throw err;
  keys.forEach(function (key, i) {
    console.log('   ' + key);
  });
});
client.hget('camping','shelter',function (err, value) {
  if (err) throw err;
  console.log('shelter 是 ' + value);
});
client.sadd('ip_address', '204.10.37.96',redis.print);
client.sadd('ip_address', '204.10.37.96',redis.print);
client.sadd('ip_address', '204.10.37.97',redis.print);
client.smembers('ip_address', function (err, members) {
  if (err) throw err;
  console.log(members);
});